<!DOCTYPE HTML>
<html lang="en">
    <head>
        <title>Hyphenator.js &ndash; Test 53</title>
        <meta http-equiv="content-type" content="text/html; charset=UTF-8">
        <style type="text/css">
            body {
                width:50%;
                margin-left:25%;
                margin-right:25%;
            }
            #test {
            	background-color: #ffd6d6;
            }
            #ref {
            	background-color: #d6ffd6;
            }
        </style>
    </head>
    <body>
		<p><a href="index.html">&lt;&lt; index</a> | <a href="test52.html">&lt;- Prev</a> | <a href="test54.html">Next -&gt;</a></p>
        <h1>Test 53</h1>
        <p id="desc">Hyphenate a form field value on onchange. (AKA hyphenate a string.)</p>
        <textarea cols="20" rows="3" id="ta1">Hyphenation is also known as syllabification.</textarea>
        <textarea cols="20" rows="3" id="ta2"></textarea>
        <script src="../Hyphenator.js" type="text/javascript"></script>
        <script type="text/javascript">
        	var hyphenator = new Worker('../Hyphenator_worker.js'), link;
        	hyphenator.postMessage(JSON.stringify({
        		type: 'config',
        		wordHyphenChar: '|'
        	}));

			function process() {
				hyphenator.onmessage = function (e) {
					var msg = JSON.parse(e.data);
					if (msg.type === 'hyphenate') {
						document.getElementById('ta2').value = msg.text;
					}
				};
				hyphenator.postMessage(JSON.stringify({
					type: 'hyphenate',
					text: document.getElementById('ta1').value,
					lang: 'en'
				}));
			}
				document.getElementById('ta1').onchange = process;
			if (window != parent) {
				document.getElementById('ta1').value = "Hyphenation is also known as syllabification";
				document.getElementById('ta1').onchange();
				window.setTimeout(function () {
					var t1 = document.getElementById('ta2').value,
					t2 = 'Hy|phen|ation is also known as syl|lab|i|fi|ca|tion',
					desc = document.getElementById('desc').firstChild.data,
					msg = {
						desc: desc,
						index: 53
					};
					if (t1 == t2) {
						msg.result = 'passed';
					} else {
						msg.result = 'failed';
					}
					parent.postMessage(JSON.stringify(msg), window.location.href);
				}, 200);
			};
        </script>
    </body>
</html>